<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-CN">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/hexo/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/hexo/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/hexo/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/hexo/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/hexo/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/hexo/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/hexo/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="开发笔记,">










<meta name="description" content="最近的项目里，有一个需要红包的功能，大概的需求如下1.商城管理平台可以发放随机红包，金额和个数可在后台自行设置，红包随机分配，类似微信红包，允许少数人领取到大包，少数人领取到小包，大多数人领取金额差不多，2.红包发送后，在app客户端会受到抢红包的提示，用户开始抢红包3.同一时间，只允许存在1个可领取的群发红包，用户对每个红包只能抢1次4.红包有有效期，过期后不可使用5.平台可以实时查看红包使用明">
<meta name="keywords" content="开发笔记">
<meta property="og:type" content="article">
<meta property="og:title" content="记一次实现群发红包功能的开发实现">
<meta property="og:url" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/index.html">
<meta property="og:site_name" content="Tony&#39;s blog">
<meta property="og:description" content="最近的项目里，有一个需要红包的功能，大概的需求如下1.商城管理平台可以发放随机红包，金额和个数可在后台自行设置，红包随机分配，类似微信红包，允许少数人领取到大包，少数人领取到小包，大多数人领取金额差不多，2.红包发送后，在app客户端会受到抢红包的提示，用户开始抢红包3.同一时间，只允许存在1个可领取的群发红包，用户对每个红包只能抢1次4.红包有有效期，过期后不可使用5.平台可以实时查看红包使用明">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/giftlist.png">
<meta property="og:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/sendgift.png">
<meta property="og:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/giftdetail.png">
<meta property="og:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/receive.png">
<meta property="og:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/received.png">
<meta property="og:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/choose.png">
<meta property="og:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/pay.png">
<meta property="og:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/wxpay.png">
<meta property="og:updated_time" content="2018-11-23T08:09:07.262Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="记一次实现群发红包功能的开发实现">
<meta name="twitter:description" content="最近的项目里，有一个需要红包的功能，大概的需求如下1.商城管理平台可以发放随机红包，金额和个数可在后台自行设置，红包随机分配，类似微信红包，允许少数人领取到大包，少数人领取到小包，大多数人领取金额差不多，2.红包发送后，在app客户端会受到抢红包的提示，用户开始抢红包3.同一时间，只允许存在1个可领取的群发红包，用户对每个红包只能抢1次4.红包有有效期，过期后不可使用5.平台可以实时查看红包使用明">
<meta name="twitter:image" content="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/giftlist.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/hexo/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Tony'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://tony_df.coding.net/2018/11/23/记一次实现群发红包功能的开发实现/">





  <title>记一次实现群发红包功能的开发实现 | Tony's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/hexo/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Tony's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">学着码代码,学着码人生;</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/hexo/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br>
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/hexo/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br>
            
            Tags
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/hexo/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br>
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://tony_df.coding.net/hexo/2018/11/23/记一次实现群发红包功能的开发实现/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tony">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/hexo/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Tony's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">记一次实现群发红包功能的开发实现</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-11-23T15:32:10+08:00">
                2018-11-23
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>最近的项目里，有一个需要红包的功能，大概的需求如下<br>1.商城管理平台可以发放随机红包，金额和个数可在后台自行设置，红包随机分配，类似微信红包，允许少数人领取到大包，少数人领取到小包，大多数人领取金额差不多，<br>2.红包发送后，在app客户端会受到抢红包的提示，用户开始抢红包<br>3.同一时间，只允许存在1个可领取的群发红包，用户对每个红包只能抢1次<br>4.红包有有效期，过期后不可使用<br>5.平台可以实时查看红包使用明细，并可以导出<br>恩，差不多就是这些需求了，还有些小细节的地方就不多说了，只看这些内容，来看一下我们的实现思路<br>从这个需求来看，一个红包的生命周期可以分为三个阶段<br>发送红包-&gt;领取红包-&gt;使用红包<br>首先，来看怎么解决发红包的问题<br>根据用户需求，红包的发送类似微信拼手气红包，不同的是这个红包有有效期，<br>那么这个问题我们在细分成两个部分，一是把红包列表生成出来，二是给这个红包设定一个有效期，过期自动作废<br>代码设这样的</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">/// &lt;summary&gt;</span><br><span class="line">/// 拆分红包</span><br><span class="line">/// &lt;/summary&gt;</span><br><span class="line">/// &lt;param name=&quot;amount&quot;&gt;红包总金额&lt;/param&gt;</span><br><span class="line">/// &lt;param name=&quot;count&quot;&gt;拆分个数&lt;/param&gt;</span><br><span class="line">/// &lt;returns&gt;&lt;/returns&gt;</span><br><span class="line">private Dictionary&lt;int, double&gt; MakeGift(double amount, int count)</span><br><span class="line">&#123;</span><br><span class="line">    Dictionary&lt;int, double&gt; dic = new Dictionary&lt;int, double&gt;(count);</span><br><span class="line">    Random rand = new Random();</span><br><span class="line">    //double t_max = 0, t_min = 0;</span><br><span class="line">    double min = 0.01;//每人最少分的1分钱</span><br><span class="line">    double safe_total, money;</span><br><span class="line">    for (int i = 0; i &lt; count; i++)</span><br><span class="line">    &#123;</span><br><span class="line">        safe_total = (amount - (count - i) * min) / (count - i);//随机红包值的安全上限</span><br><span class="line">        money = Math.Round((rand.Next(Convert.ToInt32(min * 100), Convert.ToInt32(safe_total * 100)) * 0.01), 2);//产生金额</span><br><span class="line">        dic.Add(i, money);</span><br><span class="line">        amount = amount - money;          </span><br><span class="line">    &#125;</span><br><span class="line">    return dic;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>这个方法里最核心的代码是这两行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">safe_total = (amount - (count - i) * min) / (count - i);//随机红包值的安全上限</span><br><span class="line">money = Math.Round((rand.Next(Convert.ToInt32(min * 100), Convert.ToInt32(safe_total * 100)) * 0.01), 2);//产生金额</span><br></pre></td></tr></table></figure>

<p>需要一定的数学知识才可以理解，涉及到了数学期望，正态分布等概率问题（没错，我从网上抄的现场算法，我也不懂，大学那点数学知识差不多都就着白粥喝了🙂）<br>红包发完后，需要将这个列表保存起来，每次领红包的时候从字典里找，我是把这个列表存在了Redis里<br><img src="giftlist.png" alt="giftlist"><br>红包列表生成之后，需要把红包主信息（非列表）存储起来（看也无需求，由于我们的项目需要查看红包使用明细，所以我是要把红包主信息存到关系数据库里的，这个我就不展示了），同时<br>需要设定一个定时任务来保证红包到期自动作废<br>计划任务的代码如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">/// &lt;summary&gt;</span><br><span class="line">/// 定时任务</span><br><span class="line">/// &lt;/summary&gt;</span><br><span class="line">/// &lt;param name=&quot;gift_id&quot;&gt;&lt;/param&gt;</span><br><span class="line">/// &lt;param name=&quot;ms&quot;&gt;&lt;/param&gt;</span><br><span class="line">private static void TimerTask(int gift_id, int ms)</span><br><span class="line">&#123;</span><br><span class="line">    System.Timers.Timer timer = new System.Timers.Timer();</span><br><span class="line">    timer.Enabled = true;</span><br><span class="line">    timer.Interval = ms;//执行间隔时间,单位为毫秒;此时时间间隔为1分钟  </span><br><span class="line">    timer.Start();</span><br><span class="line">    timer.AutoReset = false;//不需要自动重启，执行一次即可</span><br><span class="line">    timer.Elapsed += new System.Timers.ElapsedEventHandler((s, e) =&gt; InvalidGift(s, e, gift_id));</span><br><span class="line">&#125;</span><br><span class="line">/// &lt;summary&gt;</span><br><span class="line">/// 失效红包</span><br><span class="line">/// &lt;/summary&gt;</span><br><span class="line">private static void InvalidGift(object source, System.Timers.ElapsedEventArgs e, int gift_id)</span><br><span class="line">&#123;</span><br><span class="line">    InvalidGift();</span><br><span class="line">    BLL.user_gift bllUG = new BLL.user_gift();</span><br><span class="line">    string where = &quot;gift_id=&quot; + gift_id;</span><br><span class="line">    string strValue_UG = &quot;status=2&quot;;</span><br><span class="line">    bllUG.UpdateField(where, strValue_UG);</span><br><span class="line">    YMcms.Log.FileTxtLogs.WriteLog(&quot;自动清理过期红包&quot; + DateTime.Now, &quot;Gift_&quot;, &quot;&quot;, &quot;&quot;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>可以看到，我并没有用流行的计划任务插件（如Quartz，FluentScheduler，我用过后者，的确很强大）来做这件事，当然可能用插件的效果也很好，我觉得，只要是在生产环境中，网站的运行都是相对稳定的，所以用了多线程的方式来处理这个问题<br>代码也非常简单，实测也很有效<br>到这，发红包的流程就走完了，接下来是领红包<br>关于领红包和用红包的部分，我是在接口中做的，因为要和app对接，代码也相对简单一些<br>因为在领红包和用红包的时候，都是需要先判定红包有效性的，所以我写了一个公共的静态方法，可以根据不同的返回值来判定使用红包时的各个场景</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line">/// &lt;summary&gt;</span><br><span class="line">/// 获取红包的一些相关信息</span><br><span class="line">/// &lt;/summary&gt;</span><br><span class="line">/// &lt;param name=&quot;userid&quot;&gt;&lt;/param&gt;</span><br><span class="line">/// &lt;returns&gt;&lt;/returns&gt;</span><br><span class="line">public static Response GetGiftInfo(int userid = 0)</span><br><span class="line">&#123;</span><br><span class="line">    Response resp = new Response() &#123; code = -2 &#125;;</span><br><span class="line">    BLL.gift bllGift = new BLL.gift();</span><br><span class="line">    if (!bllGift.Exists(&quot;status=1 and is_lock=0&quot;))</span><br><span class="line">    &#123;</span><br><span class="line">        resp.code = 0;</span><br><span class="line">        resp.message = &quot;无有效红包&quot;;</span><br><span class="line">        return resp;</span><br><span class="line">    &#125;</span><br><span class="line">    else</span><br><span class="line">    &#123;</span><br><span class="line">        var dr = bllGift.GetTopRow(&quot;status&quot;, &quot;1&quot;);</span><br><span class="line">        if (dr != null)</span><br><span class="line">        &#123;</span><br><span class="line">            var gift = YMcms.Common.ModelConvertHelper&lt;Models.Models.GiftModel&gt;.DataRowToModel(dr);</span><br><span class="line">            resp.data = new &#123; id=gift.id, title = gift.title, amount = gift.amount, rel_count = gift.rel_count, str_time = gift.str_time, end_time = gift.end_time &#125;;</span><br><span class="line">            if (gift.str_time &gt; DateTime.Now || gift.end_time &lt; DateTime.Now)</span><br><span class="line">            &#123;</span><br><span class="line">                resp.code = 3;</span><br><span class="line">                resp.message = &quot;活动尚未开始或活动已过期&quot;;</span><br><span class="line">                resp.data = false;</span><br><span class="line">                return resp;</span><br><span class="line">            &#125;</span><br><span class="line">            if (userid &gt; 0)</span><br><span class="line">            &#123;</span><br><span class="line">                BLL.user_gift bllUG = new BLL.user_gift();</span><br><span class="line">                if (bllUG.ExistGift(gift.id, userid, &quot;status=0&quot;))</span><br><span class="line">                &#123;</span><br><span class="line">                    resp.code = 2;</span><br><span class="line">                    resp.message = &quot;该红包已领取&quot;;//可使用</span><br><span class="line">                    return resp;</span><br><span class="line">                &#125;</span><br><span class="line">                if (bllUG.ExistGift(gift.id, userid, &quot;status&gt;0&quot;))</span><br><span class="line">                &#123;</span><br><span class="line">                    resp.code = 3;</span><br><span class="line">                    resp.message = &quot;该红包已使用&quot;;//不可用</span><br><span class="line">                    resp.data = false;</span><br><span class="line">                    return resp;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            if (gift.rel_count &gt; 0)</span><br><span class="line">            &#123;</span><br><span class="line">                resp.code = 1;</span><br><span class="line">                resp.message = &quot;有未领取的红包&quot;;                        </span><br><span class="line">                //resp.data = true;</span><br><span class="line">            &#125;</span><br><span class="line">            else</span><br><span class="line">            &#123;</span><br><span class="line">                resp.code = -3;</span><br><span class="line">                resp.message = &quot;手慢了，红包已被抢完&quot;;</span><br><span class="line">                resp.data = 0;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    if (resp.code &lt; 1)</span><br><span class="line">    &#123;</span><br><span class="line">        bllGift.UpdateField(0, &quot;status=2&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">    return resp;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>简单说一下，Response是我自己定义的一个返回类型值，其中data字段是dynamic类型的，动态解析效率虽然没有强类型赋值高，但胜在够方便<br>不同的使用场景根据不同的code值可以根据返回的data值来组合,通过了上面函数的验证，可以发现，只要返回值code为1，就说明用户可以去抢红包<br>抢红包时，是从redis中取出giftlist，然后发到用户的账户里，这里还是需要将领取记录存储起来，这块的代码我也不展示了，真没什么可说的<br>在接下来就是使用红包了，根据客户需求，在每次扫码支付，输入完金额后，会根据订单金额，自动判断红包是否可以使用，同时记录使用详情，如果订单取消后，则红包恢复，可继续使用<br>关于这点的判断，在逻辑里，也可以沿用如上方法，只要返回值code位2，则可使用红包，在生成订单的时候在去除掉该金额即可，比较简单，就不展示代码了，<br>贴一下成品图吧<br><img src="sendgift.png" alt="sendgift"><br><img src="giftdetail.png" alt="giftdetail"><br><img src="receive.png" alt="receive"><br><img src="received.png" alt="received"><br><img src="choose.png" alt="choose"><br><img src="pay.png" alt="pay"><br><img src="wxpay.png" alt="wxpay"><br>好了，至此，一个群发红包的功能就介绍完了，回头看，发现还是蛮简单，其实做项目做产品，最重要的还是思路清晰，明朗，这只是个小例子，而且我相信各位肯定有更好的实现方式，就别吐槽我代码写的烂了，关键是思路思路~哈哈😄</p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/hexo/tags/开发笔记/" rel="tag"># 开发笔记</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/hexo/2018/10/31/亿万人的武侠梦/" rel="next" title="亿万人的武侠梦">
                <i class="fa fa-chevron-left"></i> 亿万人的武侠梦
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/hexo/2018/12/10/先用起来再细研究——异步编程（一）/" rel="prev" title="先用起来再系研究——异步编程（一）">
                先用起来再系研究——异步编程（一） <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        <!-- Go to www.addthis.com/dashboard to customize your tools -->
<div class="addthis_inline_share_toolbox">
  <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5bbb2338b87602f0" async="async"></script>
</div>

      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zOTA1My8xNTU4MA"></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Tony</p>
              <p class="site-description motion-element" itemprop="description">学习总结</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/hexo/archives/">
              
                  <span class="site-state-item-count">58</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/hexo/tags/index.html">
                  <span class="site-state-item-count">7</span>
                  <span class="site-state-item-name">tags</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Tony</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/hexo/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/hexo/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/hexo/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/hexo/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/hexo/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/hexo/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/hexo/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/hexo/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/hexo/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/hexo/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/hexo/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  












  





  

  

  

  
  

  

  

  

</body>
</html>
